﻿<?php

class regInfo
{
	public $username="";
	public $success=false;
	public $msg="";
}

include_once('conn.php');
$Sql='INSERT into user(username,password)';
if(!isset($_POST['username']) or !isset($_POST['password'])){
	$info->msg="非法访问";
	echo json_encode($info);
	die("");
}

$username = htmlspecialchars($_POST['username']);
$password = MD5($_POST['password']);
$info->username=$username;

$Sql=$Sql.' values(\''.$username.'\', \''.$password.'\')';

if(!mysql_select_db($Default_db,$conn))
{
	$info->msg="不能连接数据库".mysql_error();
	echo json_encode($info);
	die("");
}
if(!mysql_query($Sql,$conn))
{
	$info->msg="$".mysql_error();
	echo json_encode($info);
	die("");
}
else
{
	$dirName='.\\idedata\\'.$username;
	mkdir($dirName);

	$info->msg='注册成功！';
	$info->success=true;
	
	echo json_encode($info);
	exit();
}
?>
